package com.internetCafes.spms.web.customer.controller;

import com.internetCafes.spms.common.base.BaseWebController;
import com.internetCafes.spms.common.utils.entity.RR;
import com.internetCafes.spms.core.annotation.SysLog;
import com.internetCafes.spms.web.customer.bizservice.customer.IEntCustomerFollowBizService;
import com.internetCafes.spms.web.customer.model.customer.follow.CustomerFollowListRes;
import com.internetCafes.spms.web.customer.model.customer.follow.CustomerFollowSaveReq;
import com.internetCafes.spms.web.customer.model.customer.follow.CustomerFollowUpdateReq;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 客户跟进日志前端控制器
 * </p>
 *
 * @author Zj
 * @since 2021-10-20
 */
@RestController
@RequestMapping("/ent/customer/follow")
public class EntCustomerFollowController extends BaseWebController {

    @Autowired
    private IEntCustomerFollowBizService customerFollowBizService;

    /**
     * 删除跟进日志
     */
    @SysLog("跟进日志删除")
    @DeleteMapping("/{id}")
    public RR<Void> delete(@PathVariable Long id) {
        return customerFollowBizService.delete(id) ? RR.success() : RR.fail();
    }

    /**
     * 客户跟进记录列表
     */
    @GetMapping("/list/{customerId}")
    public RR<List<CustomerFollowListRes>> list(@PathVariable Long customerId) {
        return RR.success(customerFollowBizService.list(customerId));
    }

    /**
     * 新增客户跟进信息
     */
    @SysLog("新增客户跟进信息")
    @PostMapping("/save")
    public RR<Void> save(@RequestBody CustomerFollowSaveReq req){
        return customerFollowBizService.save(req) ? RR.success() : RR.fail();
    }

    /**
     * 修改客户跟进信息
     */
    @SysLog("修改客户跟进信息")
    @PutMapping()
    public RR<Void> update(@RequestBody CustomerFollowUpdateReq req) {
        return customerFollowBizService.update(req) ? RR.success() : RR.fail();
    }
}
